#ifndef CAMERA_H
#define CAMERA_H

#include "D3D11.h"
#include "xnamath.h"

// Simple camera class that lets the viewer explore the 3D scene.
//   -It keeps track of the camera coordinate system relative to the world space
//    so that the view matrix can be obtained.  
//   -It keeps track of the viewing frustum of the camera so that the projection
//    matrix can be obtained.
class Camera
{
public:
	Camera();
	~Camera();

	XMVECTOR& Position();

	XMMATRIX View()const;
	XMMATRIX Proj()const;
	
	void SetPerspective(FLOAT fovY, FLOAT aspect, FLOAT zn, FLOAT zf);
	void SetOrthographic(FLOAT viewWidth, FLOAT viewHeight, FLOAT zn, FLOAT zf);

	void LookAt(const XMVECTOR& target);
	void SetPosition(const XMVECTOR& position);
	void SetUp(const XMVECTOR& up);

	void Strafe(FLOAT distance);
	void Walk(FLOAT distance);

	void Pitch(FLOAT angle);
	void RotateY(FLOAT angle);

	void RebuildView();

private:
	XMVECTOR mPosition;
	XMVECTOR mRight;
	XMVECTOR mUp;
	XMVECTOR mLook;

	XMMATRIX mView;
	XMMATRIX mProj;
};

Camera& GetCamera();

#endif // DEMO_CAMERA_H